import {defineStore} from 'pinia';
import {Http, Cache, Helper, Constant, Msg} from 'core';
import userStore from '@/stores/framework/user';
const UserStore = userStore();
const store = {
    id: "aliyun",
    state() {
        return {
            companyConfig: {},

            companyInfo: {}
        }
    },

    getters: {

    },

    actions: {
        /**
         * 申请签约签名串
         * @returns {Promise<string|*>}
         */
        async applySign() {
            Msg.loading("加载中...")
            let {code, data} = await Http.get("/appuser/toSign4Withhold")
            Msg.loading(false);
            if(code == 200) {
                return data;
            }
            return "";
        },

        /**
         * 解约
         * @returns {Promise<void>}
         */
        async unsign(appUserId){
            Msg.loading("加载中...")
            let {code, data} = await Http.get("/appuser/unsign4Appuser", {appUserId})
            Msg.loading(false);
            if(code == 200) {
                return data;
            }
            return "";
        },

        /**
         * 检查是否已签约
         * @returns {Promise<boolean|*>}
         */
        async checkSign() {
            Msg.loading("加载中...")
            let {code, data} = await Http.get("/appuser/toCheck4Withhold").validate(false)
            Msg.loading(false);
            if(code == 200) {
                return data;
            }
            return false;
        },


    }
}

export default defineStore(store)
